<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>终端信息管理</title>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<link href="../../pages/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../pages/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="../../pages/bootstrap/animate.min.css">
<link rel="stylesheet" href="../../pages/common/styles/common.css">
<script src="../../pages/jquery/jquery-1.12.4.min.js"></script>
<script src="../../pages/bootstrap/js/bootstrap.min.js"></script>
<script src="../../pages/common/js/bootstrap-grid.js"></script>
<script src="../../pages/common/js/common.js"></script>
<script src="../../pages/fileinput/fileinput.min.js"></script>  
<link rel="stylesheet" href="../../pages/fileinput/fileinput.min.css">
<script src="../../pages/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../../pages/datetimepicker/bootstrap-datetimepicker.min.css">
<script src="../../pages/datetimepicker/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
<script src="../../pages/datetimepicker/bootstrap-datetimepicker.fr.js" type="text/javascript"></script>
<link rel="stylesheet" href="../ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../ztree/js/jquery.ztree.core.js"></script>

</head>
<body class="animated fadeInRight">

<!-- 用户管理界面显示 -->
	<div class="tabBar">
		<div class="tab">
			<img src="../../pages/images/expertImages/tab_expert_add.png">
			用户信息管理
		</div>
		<div class="tab">
			<img src="../../pages/images/expertImages/tab_expert_add.png">
			用户信息新建
		</div>
		<div class="tab">
			<img src="../../pages/images/expertImages/tab_expert_update.png">
			用户信息修改
		</div>
		<div class="tab">
			<img src="../../pages/images/expertImages/tab_expert_import.png">
			用户信息批量导入
		</div>
	</div>
	<div class="tab-main tab-active">
		<div>
			<a id="btnAdd" class="a-btn-blue"><span class="glyphicon glyphicon-plus font-size-12px"></span>&nbsp;新增</a>
			<a id="btnEdit" class="a-btn-green"><span class="glyphicon glyphicon-pencil font-size-12px"></span>&nbsp;修改</a>
			<a id="btnDel" class="a-btn-red"><span class="glyphicon glyphicon-remove font-size-12px"></span>&nbsp;删除</a>
			
			<a id="advancedSearchbtnExpert" class="a-btn-gray2 inline pull-right" style="color: #03a9f4;text-decoration: none">
			<span id="advancedSearchExpertText">高级搜索</span>&nbsp;
			<span id="advancedSearchExpertSpan" class="glyphicon glyphicon-chevron-down" title="高级搜索"></span></a>
			
			<div class="pull-right input-group" role="group" style="width: 30%;margin-right: 10px">
				<input id="searchFieldExpert" type="text" class="form-control" placeholder="输入用户账号或名称" aria-describedby="basic-addon2" >
				<span class="input-group-addon search-cusor" id="btnSearchExpert"><img alt="" src="../../pages/images/search.png"></span>
			</div>
		</div>
		
		<div id="advancedSearchExpert" style="margin-top:10px; display: none;">
			<table style="float: right;margin-right: 100px;margin-top: 10px;">
				<tr>
					<td style="padding-right: 10px;">
					</td>
					<td style="width: 300px;">
						<input id="searchOrgExpertName" type="text" class="form-control" style="width: 250px;" placeholder="请输入归属机构名称">
					</td>
					<td style="padding-right: 10px;">
					</td>
					<td style="width: 300px;">
						<input id="searchExpertPhone" type="text" class="form-control" style="width: 250px;" placeholder="请输入用户手机">
					</td>
					<td style="padding-right: 10px;">
					</td>
					<td style="width: 300px;">
						<input id="searchExpertEmail" type="text" class="form-control" style="width: 250px;" placeholder="请输入用户email">
					</td>
				</tr>
			</table>
		</div>
		
		
		<div>
			<table id="expertTable" class="table table-striped table-hover">
			  <thead>
			    <tr>
			      <th field="orgCode">归属机构编号</th>
			      <th field="orgName">归属机构名称</th>
			      <th field="account">专家账号</th>
			      <th field="name">专家名称</th>
			      <th field="phone">专家手机</th>
			      <th field="email">专家email</th>
			      <th field="terminalId">使用终端</th>
			    </tr>
			  </thead>
			  <tbody>
			  </tbody>
			</table>
			<div style="margin-bottom: 10px;">
			  <ul id="expertTable_page" class="pagination">
			  	<!-- 
			    <li><a>上一页</a></li>
			    <li class="active"><a>1</a></li>
			    <li><a>2</a></li>
			    <li><a>3</a></li>
			    <li><a>4</a></li>
			    <li><a>5</a></li>
			    <li><a>6</a></li>
			    <li><a>7</a></li>
			    <li><a>8</a></li>
			    <li><a>9</a></li>
			    <li><a>10</a></li>
			    <li><a>下一页</a></li>-->
			  </ul>
			   
			  <div class="pull-right" style="margin-top: 25px;padding-right: px">
			  	<!-- 显示分页参数  -->
			  </div>
			 </div>
		</div>
	</div>
	
	<!-- 专家信息新增页 -->
	<div class="tab-main">
		<table class="table-form" style="width: 100%;">
			<tr>
				<th width="10%"><font color="red">*</font>专家账号</td>
				<td width="40%">
					<input id="account" type="text" class="form-control inline"  aria-describedby="basic-addon1">
				</td>
				<th width="10%"><font color="red">*</font>专家密码</th>
				<td width="40%">
					<input id="password" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%"><font color="red">*</font>专家名称</th>
				<td width="40%">
					<input id="name" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家电话</th>
				<td width="40%">
					<input id="phone" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家性别</th>
				<td width="40%">
					<input id="sex" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家生日</th>
				<td width="40%">
					<input id="birthDay" type="text" class="form-control" aria-describedby="basic-addon1"  readonly="true">
				</td>
			</tr>
			<tr>
				<th width="10%">专家e-mail</th>
				<td width="40%">
					<input id="email" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家职位</th>
				<td width="40%">
					<input id="position" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家地址</th>
				<td width="40%">
					<input id="address" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">状态</th>
				<td width="40%">
					<input id="status" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家级别</th>
				<td width="40%">
					<input id="level" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%"><font color="red">*</font>归属机构</th>
				<td width="40%">
					<input id="orgId" type="text" class="form-control inline" aria-describedby="basic-addon1" placeholder="请选择机构"/>
			</tr>
			
			<tr>
				<th width="10%">知识简述</th>
				<td colspan="3">
					<textarea id="knowledge" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			
			<tr>
				<th width="10%">知识详述</th>
				<td colspan="3">
					<textarea id="knowledgeDetail" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			
			<tr>
				<th width="10%">认证描述</th>
				<td colspan="3">
					<textarea id="identiDes" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			<tr>
				<th width="10%">工作履历</th>
				<td colspan="3">
					<textarea id="workExpe" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			<tr>
				<th width="10%">成果故事</th>
				<td colspan="3">
					<textarea id="achievement" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			<tr >
				<td colspan="4" style="text-align: center;">
					<a id="save" class="a-btn-submit" onclick="addExperManagerInfo()" >提 &nbsp;&nbsp;交</a>
					<a id="reset" class="a-btn-cancel" onclick="resetExertManagerInfo()" style="margin-left: 50px;">重 &nbsp;&nbsp;置</a>
				</td>
			</tr>
		</table>
	</div>
	<!-- 专家信息修改页 -->
	<div class="tab-main">
		<table class="table-form" style="width: 100%;">
			<tr style="display: none;">
				<th width="10%">id</td>
				<td width="40%">
					<input id="u_id" type="text" class="form-control inline"  aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%"><font color="red">*</font>专家账号</td>
				<td width="40%">
					<input id="u_account" type="text" class="form-control inline"  aria-describedby="basic-addon1"  readonly="true">
				</td>
				<th width="10%"><font color="red">*</font>专家密码</th>
				<td width="40%">
					<input id="u_password" type="text" class="form-control"  aria-describedby="basic-addon1"  readonly="true">
				</td>
			</tr>
			<tr>
				<th width="10%"><font color="red">*</font>专家名称</th>
				<td width="40%">
					<input id="u_name" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家电话</th>
				<td width="40%">
					<input id="u_phone" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家性别</th>
				<td width="40%">
					<input id="u_sex" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家生日</th>
				<td width="40%">
					<input id="u_birthDay" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家e-mail</th>
				<td width="40%">
					<input id="u_email" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">专家职位</th>
				<td width="40%">
					<input id="u_position" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家地址</th>
				<td width="40%">
					<input id="u_address" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">状态</th>
				<td width="40%">
					<input id="u_status" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">专家级别</th>
				<td width="40%">
					<input id="u_level" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%"><font color="red">*</font>归属机构</th>
				<td width="40%">
					<input id="u_orgId" type="text" class="form-control inline" aria-describedby="basic-addon1" placeholder="请选择机构"/>
				</td>
			</tr>
			
			<tr>
				<th width="10%">知识简述</th>
				<td colspan="3">
					<textarea id="u_knowledge" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			
			<tr>
				<th width="10%">知识详述</th>
				<td colspan="3">
					<textarea id="u_knowledgeDetail" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			
			<tr>
				<th width="10%">认证详述</th>
				<td colspan="3">
					<textarea id="u_identiDes" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			
			<tr>
				<th width="10%">工作履历</th>
				<td colspan="3">
					<textarea id="u_workExpe" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			<tr>
				<th width="10%">成果故事</th>
				<td colspan="3">
					<textarea id="u_achievement" class="form-control" style="width:91.5%;height:70px;"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="4" style="text-align: center;">
					<a class="a-btn-submit" id="update" onclick="updateExperManagerInfo()">提 &nbsp;&nbsp;交</a>
				</td>
			</tr>
		</table>
	</div>
	<div class="tab-main" >	
		<div>
			<form id="uploadForm" action="${ctx}/user/exportUsers" method="post" enctype="multipart/form-data">
				<table style="width: 100%">
					<tr>
						<th width="180">
							专家批量导入(*.xlsx\*.xls)		
						</th>
						<td width="50%">
							<input id="file" type="file"  class="row" name="file">
						</td>
						<td style="padding-left: 5px;">
							<a class="a-btn-importfile" onclick="importUsers()">导入文件</a>
							<a class="a-btn-downloadfile" onclick="downloadTemp()">下载模板</a>
						</td>
					</tr>
					<tr>
						<td>
							<a class="a-btn-blue" onclick="confirmTempUsers()">确定</a>		
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div>
			<table id="expertTempTable" class="table table-striped table-hover">
			  <thead>
			    <tr>
			      <th field="parentOrgCode">归属机构编号</th>
			      <th field="parentOrgName">归属机构名称</th>
			      <th field="account">专家账号</th>
			      <th field="name">专家名称</th>
			      <th field="phone">专家手机</th>
			      <th field="email">专家email</th>
			    </tr>
			  </thead>
			  <tbody>
			  </tbody>
			</table>
			<div style="margin-bottom: 10px;">
			  <ul id="expertTempTable_page" class="pagination">
			  	<!-- 
			    <li><a>上一页</a></li>
			    <li class="active"><a>1</a></li>
			    <li><a>2</a></li>
			    <li><a>3</a></li>
			    <li><a>4</a></li>
			    <li><a>5</a></li>
			    <li><a>6</a></li>
			    <li><a>7</a></li>
			    <li><a>8</a></li>
			    <li><a>9</a></li>
			    <li><a>10</a></li>
			    <li><a>下一页</a></li>-->
			  </ul>
			   
			  <div class="pull-right" style="margin-top: 25px;padding-right: px">
			  	<!-- 显示分页参数  -->
			  </div>
			 </div>
		</div>
			<!-- 
		<table style="width: 70%">
			<tr>
				<th style="width:180px;">
					用户批量导入(*.xlsx\*.xls):		
				</th>

				<td style="width:350px;">
					<input id="file" type="file"  class="" name="file" style="width:100px">
				</td>

				<td style="width:225px;padding-left: 10px;">
					<a class="a-btn-green" onclick="exportUsers()">导入文件</a>
					<a class="a-btn-blue" onclick="downloadTemp()">下载模板</a>
				</td>
			</tr>
		</table>
		 -->
	</div>
</body>
<script type="text/javascript">


$("#btnAdd").on("click",function(){
	$(".tab").eq(1).click();
	
});

$(document).ready(function() {
	$("#expertTable").initGrid(15);
	$(".tab").eq(0).click();
    query();
    initFileInput("file");
    initDate();
    initTreebox();
});

function query(){
	var pageSize = parseInt(window["expertTable_page"].pageSize);
	var pageNum = parseInt(window["expertTable_page"].pageNum);
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/expert/getExpertList',
        data:{
        	pageNum:pageNum,
        	pageSize:pageSize,
        	orgName:$("#searchOrgExpertName").val(),
        	phone:$("#searchExpertPhone").val(),
        	email:$("#searchExpertEmail").val(),
        	searchField:$("#searchFieldExpert").val()
        },
        success: function (data) {
        	$("#expertTable").loadGrid(data);
        },
		error:function(){
		}
    });
}

function initTreebox(){
	//组织机构树
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/org/getOrgTree',
        success: function (data) {
        	$("#orgId").initComboTree(data);
        	$("#u_orgId").initComboTree(data);
        },
		error:function(){
		}
    });	
}

/**
 * 初始化日期控件
 */
function initDate(){
	$.fn.datetimepicker.dates['zh-CN'] = {
 		    days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
 		    daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
 		    daysMin:  ["日", "一", "二", "三", "四", "五", "六", "日"],
 		    months: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
 		    monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
 		    today: "今天",
 		    suffix: [],
 		    meridiem: ["上午", "下午"]
 			};
 	
    $("#birthDay").datetimepicker({
        format: "yyyy-mm-dd",
    	language:'zh-CN',
        autoclose: true,
        todayBtn: true,
        pickerPosition: "bottom-left",
		minView:2
    	});
    
    $("#u_birthDay").datetimepicker({
        format: "yyyy-mm-dd",
    	language:'zh-CN',
        autoclose: true,
        todayBtn: true,
        pickerPosition: "bottom-left",
		minView:2
    	});
}


//初始化导入文件样式
function initFileInput(ctrlName) {      
	 var control = $('#' + ctrlName);   
	 control.fileinput({  
	     language: 'zh', //设置语言  
	     showUpload: false, //是否显示上传按钮  
	     showPreview:false,//显示预览框
	     showRemove:true,  
	      dropZoneEnabled: false,  
	     showCaption: true,//是否显示标题  
	     allowedPreviewTypes: [''],  
	        allowedFileTypes: ['image'],  
	        allowedFileExtensions:  ['xlsx', 'xls'],  
	        maxFileSize : 2000,  
	        maxFileCount: 1,  
	        uploadAsync: false, //同步上传    
	 }); 
}

//新增用户
function addExperManagerInfo(){
		var account = $("#account").val(); 
		var password = $("#password").val(); 
		var name = $("#name").val(); 
		var orgId = $("#orgId").val(); 
		var email = $("#email").val();
		if(account == null||account==""){
			$.MsgBox.Alert("提示","账号不能为空!");
			$("#account").focus();
		}else if(password == null||password==""){	
			$.MsgBox.Alert("提示","密码不鞥为空!");
			$("#password").focus();
		}else if(name == null||name==""){	
			$.MsgBox.Alert("提示","用户名称不能为空!");
			$("#name").focus();
		}else if(orgId == null||orgId==""){	
			$.MsgBox.Alert("提示","专家池未设定，请输入!");
			$("#orgId").focus();
		}else if(email!=null&&email!=""&&emailcheck(email)==false){
			$.MsgBox.Alert("提示","邮箱格式不正确!");
			$("#email").focus();
		}else{
			$.MsgBox.Confirm("提示","确定添加!",function(){
				$.ajax({
			        type: "post",
			        dataType: "json",
			        url: '${ctx}/expert/addExpert',
			        data:{
			        	account:$("#account").val(),
			        	password:$("#password").val(),
			        	name:$("#name").val(),
			        	phone:$("#phone").val(),
			        	sex:$("#sex").val(),
			        	//birthDay:$("#birthDay").datebox("getValue"),
			        	birthDay:$("#birthDay").val(),
			        	email:$("#email").val(),
			        	position:$("#position").val(),
			        	address:$("#address").val(),
			        	status:$("#status").val(),
			        	orgId:$("#orgId").getComboTreeValue(),
			        	knowledge:$("#knowledge").val(),
			        	knowledgeDetail:$("#knowledgeDetail").val(),
			        	level:$("#level").val(),
			        	identiDes:$("#identiDes").val(),
			        	workExpe:$("#workExpe").val(),
			        	achievement:$("#achievement").val()
			        },
			        success: function (data) {
			        	if(data.status=="1"){
			        	  $.MsgBox.Alert("提示",data.msg);
			        	  $(".tab-main tr td input").val("");
			      		  $(".tab").eq(0).click();
				          query();
			        	}else{
			        		$.MsgBox.Alert("提示",data.msg); 
			        		$("#account").focus();
			        	}
			        },
					error:function(){
						$.MsgBox.Alert("提示",data.msg);
						$("#account").focus();
					}
			    });
			});
		}
}

//新增用户信息重置
function resetExertManagerInfo(){
	$.MsgBox.Confirm("提示","确定重置信息？",function(){
		$(".tab-main tr td input").val("");
		$("#account").focus();
	});
}

//修改用户信息


$("#btnEdit").on("click",function(){
	var result = $("#expertTable").getSelections();
	if(parseInt(result.length)==0){
		$.MsgBox.Alert("提示","请选择一条记录!");
	}else if(parseInt(result.length)==1){
		$(".tab").eq(2).click();
		$("#u_id").val(result[0].id),
    	$("#u_account").val(result[0].account),
    	$("#u_password").val(result[0].password),
    	$("#u_name").val(result[0].name),
    	$("#u_phone").val(result[0].phone),
    	$("#u_sex").val(result[0].sex),
    	//birthDay:$("#u_birthDay").datebox("getValue"),
    	$("#u_birthDay").val(result[0].birthDay),
    	$("#u_email").val(result[0].email),
    	$("#u_position").val(result[0].position),
    	$("#u_address").val(result[0].address),
    	$("#u_status").val(result[0].status),
    	$("#u_orgId").setComboTreeValue(result[0].orgId),
    	$("#u_knowledge").val(result[0].knowledge),
    	$("#u_knowledgeDetail").val(result[0].knowledgeDetail),
    	$("#u_level").val(result[0].level),
    	$("#u_identiDes").val(result[0].identiDes),
    	$("#u_workExpe").val(result[0].workExpe),
    	$("#u_achievement").val(result[0].achievement)
	}else{
		$.MsgBox.Alert("提示","只能选择一条记录!");
	}
	
});



 function updateExperManagerInfo(){
	var account = $("#u_account").val();
	var u_password = $("#u_password").val(); 
	var u_name = $("#u_name").val(); 
	var u_orgId = $("#u_orgId").val(); 
	var u_email = $("#u_email").val();
	
	if(u_account == null||u_account==""){
		$.MsgBox.Alert("提示","账号不能为空!");
		$("#u_account").focus();
	}else if(u_password == null||u_password==""){	
		$.MsgBox.Alert("提示","密码不能为空!");
		$("#u_password").focus();
	}else if(u_name == null||u_name==""){	
		$.MsgBox.Alert("提示","用户名称不能为空!");
		$("#u_name").focus();
	}else if(u_orgId == null||u_orgId==""){	
		$.MsgBox.Alert("提示","专家池未设定，请输入!");
		$("#u_orgId").focus();
	}else if(u_email!=null&&u_email!=""&&emailcheck(u_email)==false){
		$.MsgBox.Alert("提示","邮箱格式不正确!");
		$("#u_email").focus();
	}else{		
		$.MsgBox.Confirm("提示","确定修改用户信息？",function(){
			$.ajax({
		        type: "post",
		        dataType: "json",
		        url: '${ctx}/expert/updateExpert',
		        data:{
		        	id:$("#u_id").val(),
		        	account:$("#u_account").val(),
		        	password:$("#u_password").val(),
		        	name:$("#u_name").val(),
		        	phone:$("#u_phone").val(),
		        	sex:$("#u_sex").val(),
		        	//birthDay:$("#u_birthDay").datebox("getValue"),
		        	birthDay:$("#u_birthDay").val(),
		        	email:$("#u_email").val(),
		        	position:$("#u_position").val(),
		        	address:$("#u_address").val(),
		        	status:$("#u_status").val(),
		        	terminalId:$("#u_level").val(),
		        	orgId:$("#u_orgId").getComboTreeValue(),
		        	knowledge:$("#u_knowledge").val(),
		        	terminalId:$("#u_knowledgeDetail").val(),
		        	terminalId:$("#u_identiDes").val(),
		        	terminalId:$("#u_workExpe").val(),
		        	terminalId:$("#u_achievement").val()
		        },
		        success: function (data) {
		        	if(data.status=="1"){
		        		$.MsgBox.Alert("提示",data.msg);
			        	query();
			        	$(".tab-main tr td input").val("");
			        	$(".tab").eq(0).click();
		        	}else{
		        		$.MsgBox.Alert("提示",data.msg); 
		        		$("#account").focus();
		        	}
		        },
				error:function(){
					$.MsgBox.Alert("提示",data.msg);
				}
		    });
		});
	}
}

//删除数据
 $("#btnDel").on("click",function(){
 	var result = $("#expertTable").getSelections();
 	var expertIds = [];
 	for(var i=0; i<result.length; i++){
 		expertIds.push(result[i].id);
 	}
 	if(parseInt(result.length)==0){
 		$.MsgBox.Alert("提示","请选择一条记录!");
 	}else{
 		$.MsgBox.Confirm("提示","确定修改用户信息？",function(){
 			$.ajax({
	 	        type: "post",
	 	        dataType: "json",
	 	        url: '${ctx}/expert/deleteExperts',
	 	        data:{
	 	        	"expertIds":expertIds.join(",")
	 	        },
	 	        success: function (data) {
	 	        	if(data.status=='1'){
	 	        		$.MsgBox.Alert("提示",data.msg);
	 	        		query();
	 	        	}else{
	 	        		$.MsgBox.Alert("提示",data.msg);
	 	        	}
	 	        },
	 			error:function(){
	 				$.MsgBox.Alert("提示",data.msg);
	 			}
	 	    }); 
 		});
	}
 });

 /**
  * 文件导入
  */
function importUsers(){
	$.MsgBox.Confirm("提示","确定要导入专家信息？",function(){
		$.ajax({
			url : '${ctx}/expert/exportExperts',
			type : 'POST',
			cache : false,
			data : new FormData($('#uploadForm')[0]),
			processData : false,
			contentType : false
		}).done(function(res) {
		
			if(res.status=="1"){
				$.MsgBox.Alert("提示",data.msg);
				$("#expertTempTable").initGrid(0);
				$("#expertTempTable").loadGrid(JSON.parse(res.data));
			}else{
				$.MsgBox.Alert("提示",data.msg); 
			}
		}).fail(function(res) {
			$.MsgBox.Alert("提示",data.msg); 
		});
	});
}
 	
 /**
  * 文件导出
  */
function downloadTemp() {
	window.location.href = "${ctx}/expert/downloadTemp";
}

 /**
  * 把数据保持入库
  */
function confirmTempUsers(){
	var rows = $('#expertTempTable').getSelections();
	if(rows.length < 1){
		$.MsgBox.Alert("提示","请选择一条记录!");
		return ;
	}
	
	var expertList = new Array();

	for(var i=0; i<rows.length; i++){
		var expert = new Object();
		expert.account = rows[i].account;
		expert.password = rows[i].password;
		expert.name = rows[i].name;
		expert.phone = rows[i].phone;
		expert.sex = rows[i].sex;
		expert.birthDay = rows[i].birthDay;
		expert.email = rows[i].email;
		expert.position = rows[i].position;
		expert.address = rows[i].address;
		expert.knowledge = rows[i].knowledge;
		expertList.push(expert);
	}
	
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/expert/confirmTempExperts',
        data:{
        	"expertListString":JSON.stringify(expertList)
        },
        success: function (data) {
        	if(data.status=='1'){
        		query();
        		$.MsgBox.Alert("提示",data.msg); 
        		$('#expertTempTable').deleteSelections();
        	}else{
        		$.MsgBox.Alert("提示",data.msg);
        	}
        },
		error:function(){
			$.MsgBox.Alert("提示",data.msg);
		}
    });
	
}
 	
function emailcheck(email){
	var szReg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/; 
	var flag = szReg.test(email);
	return flag;
}

$("#advancedSearchbtnExpert").on("click",function(){
	 if($("#advancedSearchExpert").css('display')=="block"){
	    $("#advancedSearchExpertText").html('高级搜索');
		$("#advancedSearchExpertSpan").removeClass('glyphicon glyphicon-chevron-up');
		$("#advancedSearchExpertSpan").addClass('glyphicon glyphicon-chevron-down');
		$("#advancedSearchExpert").css("display","none");
		orgName:$("#searchOrgExpertName").val('');
    	phone:$("#searchExpertPhone").val('');
    	email:$("#searchExpertEmail").val('');
	 }else{
	    $("#advancedSearchExpertText").html('收起条件');
		$("#advancedSearchExpertSpan").removeClass('glyphicon glyphicon-chevron-down');
		$("#advancedSearchExpertSpan").addClass('glyphicon glyphicon-chevron-up');
		$("#advancedSearchExpert").css("display","block");
	 }
});


$("#btnSearchExpert").click(function(){
	query();
});

</script>
</html>